#ifndef AIENGINE_H
#define AIENGINE_H

#include "Enemy.h"
#include "Camera.h"
#include <vector>
#include "KdTree.h"

class AIEngine {
public:
	AIEngine(Camera *camera_, KdTree *kdTree_);

	void placeEnemy(unsigned int index);	
	void updateEnemies();
	void placeCharacter();
	void addEnemy(GLdouble x, GLdouble y, GLdouble z, GLdouble speed);
	void characterCollidesWithEnemy();
	int getNumEnemies() { return enemies->size(); }
	std::vector<Enemy*>* getEnemies() { return enemies; }
	Enemy* getEnemy(unsigned int index) { return enemies->at(index); }

private:
	void updateAutonomousEnemy(Enemy *enemy);
	void updateFollowingEnemy(Enemy *enemy, Enemy *enemy);
	bool isFrontCollides(Enemy *enemy, int ratio);
	bool isLeftCollides(Enemy *enemy, int ratio);
	bool isRightCollides(Enemy *enemy, int ratio);

	Camera* camera;
	std::vector<Enemy*> *enemies;
	KdTree *kdTree;
};

#endif
